package cn.player.download;

import android.os.Parcel;
import android.os.Parcelable;

public class DownloadInfo implements Parcelable {
    public static final int INIT_FAILED_CACHE_FILE_DISABLE = -5; // 缓存文件丢失
    public static final int INIT_FAILED_NO_SDCARD = -4; // SD卡没存在
    public static final int INIT_FAILED_EXIST = -3; // 任务已经存在
    public static final int INIT_FAILED_BASE_DATA_ERROR = -2; // 初始化信息错误
    public static final int INIT_FAILED = -1; // 初始化过程错误
    public static final int INIT_IDLE = 0; // 尚未初始化
    public static final int INIT_SUCCESS = 1; // 初始化成功

    public static final int DOWNLOAD_READY = 0; // 准备下载
    public static final int DOWNLOAD_ING = 10; // 正在下载
    public static final int DOWNLOAD_STOP = 20; // 暂停
    public static final int DOWNLOAD_SUCCESS = 30; // 下载完成
    public static final int DOWNLOAD_ERR = 40; // 下载错误
    public static final int DOWNLOAD_NOT_EXISTS = 100; // 不存在

    private String uid;//userId;
    private String vid; // vid
    private String filename; // 文件名称
    private String requestUrl; // 初始请求地址
    private String targetFilePath;  //存储文件路径
    private int priority;//任务优先级

    private long fileSize;
    private float progress; // 下载进度
    private int downloadState = DOWNLOAD_READY; // 下载状态

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getVid() {
        return vid;
    }

    public void setVid(String vid) {
        this.vid = vid;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public String getRequestUrl() {
        return requestUrl;
    }

    public void setRequestUrl(String requestUrl) {
        this.requestUrl = requestUrl;
    }

    public long getFileSize() {
        return fileSize;
    }

    public void setFileSize(long fileSize) {
        this.fileSize = fileSize;
    }

    public String getTargetFilePath() {
        return targetFilePath;
    }

    public void setTargetFilePath(String targetFilePath) {
        this.targetFilePath = targetFilePath;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public float getProgress() {
        return progress;
    }

    public void setProgress(float progress) {
        this.progress = progress;
    }

    public int getDownloadState() {
        return downloadState;
    }

    public void setDownloadState(int downloadState) {
        this.downloadState = downloadState;
    }

    public DownloadInfo() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.uid);
        dest.writeString(this.vid);
        dest.writeString(this.filename);
        dest.writeString(this.requestUrl);
        dest.writeString(this.targetFilePath);
        dest.writeInt(this.priority);
        dest.writeLong(this.fileSize);
        dest.writeFloat(this.progress);
        dest.writeInt(this.downloadState);
    }

    protected DownloadInfo(Parcel in) {
        this.uid = in.readString();
        this.vid = in.readString();
        this.filename = in.readString();
        this.requestUrl = in.readString();
        this.targetFilePath = in.readString();
        this.priority = in.readInt();
        this.fileSize = in.readLong();
        this.progress = in.readFloat();
        this.downloadState = in.readInt();
    }

    public static final Creator<DownloadInfo> CREATOR = new Creator<DownloadInfo>() {
        @Override
        public DownloadInfo createFromParcel(Parcel source) {
            return new DownloadInfo(source);
        }

        @Override
        public DownloadInfo[] newArray(int size) {
            return new DownloadInfo[size];
        }
    };
}
